package com.example.app03.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.app03.bean.Category;
import com.example.app03.dao.CategoryDao;
import com.example.app03.service.ICategoryService;

@Service
public class categoryServiceImpl implements ICategoryService{
	@Autowired
	private CategoryDao categoryDao;
	@Override
	public List<Category> findAll(){
		return categoryDao.selectAll();
	}
	
	
	@Override
	public Category findById(long id) {
		return categoryDao.selectById(id);
	}

	@Override
	public void deleteById(long id) {
		categoryDao.deleteById(id);
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void saveOrUpdate(Category category) {
		if(category.getId() == null) {
			categoryDao.save(category);
		}
		else {
			categoryDao.update(category);
		}
		
	}
	
	
	
}
